package work803.work1;

import java.util.List;
import java.util.Scanner;

import static work803.work1.Service.*;

public class Client {
  static Service service = new Service();
  public static void main(String[] args) {

    Scanner input = new Scanner(System.in);
    do{
      System.out.println("\t学生档案管理系统");
      System.out.println("-----------------------------");
      System.out.println("\t1、显示所有学生");
      System.out.println("\t2、删除学生");
      System.out.println("\t3、新增学生");
      System.out.println("\t4、修改学生");
      System.out.println("\t0、退出系统");
      System.out.println("-----------------------------");
      System.out.print("请选择:");
      int choice = input.nextInt();
      switch (choice){
        case 0:
          System.out.println("感谢使用本程序！");
          System.exit(0);
          break;
        case 1:
          List<Student> students = selectAll();
          students.forEach(System.out::println);
          break;
        case 2:
          System.out.println("请输入学号：");
          int stuNo1 = input.nextInt();
          boolean result1 =  delStudent(stuNo1);
          if(result1){
            System.out.println("删除学生信息成功！");
          }
          else {
            System.out.println("删除学生信息失败！");
          }
          break;
        case 3:
          System.out.println("请输入学号：");
          int stuNo = input.nextInt();
          System.out.println("请输入姓名：");
          String stuName = input.next();
          System.out.println("请输入年龄：");
          int stuAge = input.nextInt();
          System.out.println("请输入身份证：");
          String idCard = input.next();
          Student newStu = new Student(stuNo,stuAge,stuName,idCard);
          boolean result = addStudent(newStu);
          if(result){
            System.out.println("新增学生信息成功！");
          }
          else {
            System.out.println("新增学生信息失败！");
          }
          break;
        case 4:
          System.out.println("请输入学号：");
          int stuNo2 = input.nextInt();
          System.out.println("请输入姓名：");
          String stuName2 = input.next();
          System.out.println("请输入年龄：");
          int stuAge2 = input.nextInt();
          System.out.println("请输入身份证：");
          String idCard2 = input.next();
          Student newStu2 = new Student(stuNo2,stuAge2,stuName2,idCard2);
          boolean result2 = updateStudent(newStu2);
          if(result2){
            System.out.println("修改学生信息成功！");
          }
          else {
            System.out.println("修改学生信息失败！");
          }
          break;
      }
    }while (true);

  }
}
